import pymysql
try:
    connect=pymysql.connect(
        host='127.0.0.1',
        password='root',
        db='wo',
        user='root',
        charset='utf8'
    )
    cursor=connect.cursor()
    sql='insert into teacherinfo(tno,tname) values(%s,%s)'
    val=[['250','梁志超'],['2500','laingji']]
    cursor.executemany(sql,val)
    connect.commit()
except Exception as e:
    connect.rollback()
    print(e)
finally:
    cursor.close()
    connect.close()